﻿@using CNKI.TPI.Web.Base
@using CNKI.TPI.Web.Search.BLL
<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $.ajax({
            type: "GET",
            url: "@Html.Raw(Url.Action("IsFirstDigitalFileExsit", "File"))",
            data: { "dbID": $("#dbID").val(), "recordId": $("#recordId").val(), "MediaType": $("#mediaType").val() },
            success: function (msg) {
                var addressaudio = $('#audioaddress').val();
                var audioname = $('#audioname').val();
                $(".jp-title").css("color", "#000");
                if (msg == 0) {
                    audioname = "文件不存在!";
                    $(".jp-title").css("color", "red");
                }
                else if (msg == 2) {
                    audioname = '不支持该类型的文件!';
                    $(".jp-title").css("color", "red");
                }
                $("#jquery_jplayer_1").jPlayer({
                    ready: function (event) {
                        $(this).jPlayer("setMedia", {
                            title: audioname,
                            mp3: addressaudio
                        });
                    },
                    swfPath: "Content/jplayer",
                    supplied: "mp3, m4a, oga",
                    wmode: "window",
                    useStateClassSkin: true,
                    autoBlur: false,
                    smoothPlayBar: true,
                    keyEnabled: true,
                    remainingDuration: true,
                    toggleDuration: true
                });
            },
            error: function (e) {
                messageAlert("系统异常，请刷新后重试")
            }
        })
    })
    function playaudio(sid, id, filename) {

        var datastr = { "dbID": id, "sysID": sid, "flage": 0 };
        var url = "";
        $.ajax({
            async: false,
            type: "get",
            url: timestamp("@Html.Raw(Url.Action("GetStreamUrl", "Detail"))"),
            data: datastr,
            success: function (msg) {
                url = msg;
            },
            error: function (e) {
                messageAlert("系统异常，请刷新后重试")
            }
        })
        $(".jp-title").css("color", "#000");
        if (url == "0") {
            filename = '文件不存在!';
            $(".jp-title").css("color", "red");
        }
        else if (url == "2") {
            filename = "不支持该类型的文件";
            $(".jp-title").css("color", "red");
        }
        var audiobj = $("#jquery_jplayer_1");
        audiobj.jPlayer('stop');
        audiobj.jPlayer("clearMedia");
        audiobj.jPlayer("setMedia", {
            title: filename,
            mp3: url
        });
        audiobj.jPlayer("play");

    }
    //解决浏览器缓存
    function timestamp(url) {
        var getTimestamp = new Date().getTime();
        if (url.indexOf("?") > -1) {
            url = url + "&t=" + getTimestamp
        } else {
            url = url + "?t=" + getTimestamp
        }
        return url;
    }
</script>
<!--面包屑一-->
<div class="crumbLink">
    @*<a href="javascript:void(0);">首页</a>&gt;<a href="javascript:void(0);">检索</a>&gt;期刊*@

</div>
<input type="hidden" id="dbID" name="dbID" value="@ViewBag.dbId" />
<input type="hidden" id="recordId" name="recordId" value="@ViewBag.recordId" />
<input type="hidden" id="mediaType" name="mediaType" value="@ViewBag.Type" />
<input type="hidden" id="audioaddress" name="audioaddress" value="@ViewBag.PlayStream" />
<input type="hidden" id="audioname" name="audioname" value="@ViewBag.PlayStreamName" />
@if (ViewBag.DetialField != null && ViewBag.DetialField.Rows.Count > 0)
{
    <h2 class='doc-title'>@Html.Raw(ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0))</h2>
    <div class="doc-value">
        @{
            string view = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_BROWSERATE");
            string download = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_DOWNLOADRATE");
        }
        浏览量：@Html.Raw(@view == "" ? "0" : @view)
        下载量：@Html.Raw(@download == "" ? "0" : @download)

        @{
            int type = (int)MediaType.Audio;
            if (SessionHelper.HasDownloadRight(ViewBag.dbId))
            {

                if (ViewBag.FileCount != null && ViewBag.FileCount > 1)
                {
                    <a onclick="showdown()" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-download"></i>下载</a>
                }
                else
                {
                    <a onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type, '@Html.Raw(Url.Action("IsShowDown", "File"))','-1','@ViewBag.DownType')" class='btn btn-m btn-prim-f ml10'>
                        <i class="iconfont icon-download"></i>下载
                    </a>
                }
            }
            if (SessionHelper.GetUserInfo() != null
            && ((ConfigHelper.IsAnonymousControlEnabled() && SessionHelper.GetUserInfo().UserCode.ToUpper() != ConfigHelper.GetAnonymousAccount().ToUpper())
            || !ConfigHelper.IsAnonymousControlEnabled()))
            {
                <span class="favCate">
                    <a onclick="showFavCate('@ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0)')" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-star"></i>收藏</a>
                </span>
            }
        }
    </div>
    @* “音频下载”弹层 *@
            <div class="talkDiv Down" style="top: 50%; left: 50%; margin-left: -280px; display: none">
                <div class="talkDiv-title" style="height: 40px; line-height: 40px; padding-left: 10px; font-size: 16px; position: relative; border-bottom: 1px solid #DADADA; background-color: #efefef; font-family: 微软雅黑">
                    <span>下载</span>
                    <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closedown()" style="top: 0px"><i class="iconfont icon-error3"></i></a>
                </div>
                <div class="talkDiv-body" style="padding-top: 25px">
                    <ul class="video-download">
                        @if (ViewBag.FileInfoAll != null)
                        {
                            foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE m in ViewBag.FileInfoAll)
                            {

                                <li>
                                    @m.FILENAME
                                    <a class="btn btn-m btn-prim-f posa" style="margin-right:40px"
                                       onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type, '@Html.Raw(Url.Action("IsShowDown", "File"))','@m.SYSID','@ViewBag.DownType')">点击下载</a>
                                </li>
                            }
                        }

                    </ul>
                </div>
            </div>
            <div class="doc-con clearfix posr video-con">
                <div class='video-con-r'>
                    <div class="video-con-r-in">
                        <P></P>
                        @foreach (System.Data.DataRow dr in ViewBag.DetialField.Rows)
                {
                    int i = 0;
                    System.Data.DataRow columnInfo = null;
                    foreach (System.Data.DataColumn column in ViewBag.DetialField.Columns)
                    {
                        if (column.ColumnName.StartsWith("SYS_FLD_") || column.ColumnName == "浏览量" || i == 0)
                        {
                            i++;
                            continue;
                        }
                        columnInfo = ViewBag.RColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName))[0];
                        string colname = column.ColumnName;
                        if (!string.IsNullOrEmpty(columnInfo["DispName"].ToString()))
                        {
                            colname = columnInfo["DispName"].ToString();
                        }
                        if (!string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                        {
                                    <p>@colname：@Html.Raw(dr[column.ColumnName].ToString())</p>
                                }
                            }
                        }

                    </div>
                </div>
                <div class='video-con-l'>
                    <img width="650" height="340" src="@ViewBag.Pic" alt="" />
                    <!-- 音频插件 -->
                    <div class="tc ptb20 posr list-audio" style="text-align:left;margin:0px;padding:0px;">

                        <div id="jp_container_1" class="jp-audio" role="application" aria-label="media player" style="width: 650px; height: 87px; border: none">
                            <div class="jp-type-single">
                                <div class="jp-gui jp-interface" style="height:68px">
                                    <div class="jp-controls">
                                        <button class="jp-play" role="button" tabindex="0">play</button>
                                        <button class="jp-stop" role="button" tabindex="0">stop</button>
                                    </div>
                                    <div class="jp-progress">
                                        <div class="jp-seek-bar">
                                            <div class="jp-play-bar"></div>
                                        </div>
                                    </div>
                                    <div class="jp-volume-controls">
                                        <button class="jp-mute" role="button" tabindex="0">mute</button>
                                        <button class="jp-volume-max" role="button" tabindex="0">max volume</button>
                                        <div class="jp-volume-bar">
                                            <div class="jp-volume-bar-value"></div>
                                        </div>
                                    </div>
                                    <div class="jp-time-holder">
                                        <div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
                                        <div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
                                        <div class="jp-toggles">
                                            <button class="jp-repeat" role="button" tabindex="0">repeat</button>
                                        </div>
                                    </div>
                                </div>
                                <div class="jp-details">
                                    <div class="jp-title" aria-label="title" style="color:red;margin-top:1px;padding:0px;"></div>
                                </div>
                                <div class="jp-no-solution">
                                    <span>Update Required</span>
                                    To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.

                                </div>
                            </div>
                        </div>
                        <div id="jquery_jplayer_1" class="jp-jplayer"></div>
                    </div>
                </div>

            </div>


            <div class="xg-search xs-doc">
                <h2><span>在线收听章节列表</span></h2>
                <table class="table table-grey table-noedge" border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tbody>
                        @{int Mp3num = 0, num = 0;}
                        @if (ViewBag.FileInfo != null)
                {
                    foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE m in ViewBag.FileInfo)
                    {
                        if (FileService.CheckAudio(m.FORMAT))
                        {
                            if (Mp3num % 3 == 0)
                            {
                                        @Html.Raw("<tr><td><a onclick=\"playaudio('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td>");
                            }
                            else if (Mp3num % 3 == 2 || num == ViewBag.FileInfo.Count)
                            {
                                        @Html.Raw("<td><a onclick=\"playaudio('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td></tr>");
                            }
                            else
                            {
                                        @Html.Raw("<td><a onclick=\"playaudio('" + m.SYSID + "','" + @ViewBag.dbId + "','" + m.FILENAME + "')\">" + m.FILENAME + "</a></td>");
                            }
                            Mp3num++;
                        }
                        num++;
                    }
                }
                    </tbody>
                </table>
                @*        <div class="open"><a href="">展开</a></div>*@
            </div>
                            }
